import Mock, { Random } from "mockjs";

import { builder } from "./utils";

let baseUrl = "http://localhost:29999";

Mock.setup({
  timeout: 400,
});

export const productTypeList = [
  {
    id: 1,
    title: "Chair",
    iconStyle: "flaticon-armchair",
  },
  {
    id: 2,
    title: "Bed",
    iconStyle: "flaticon-single-bed",
  },
  {
    id: 3,
    title: "Sofa",
    iconStyle: "flaticon-sofa",
  },
  {
    id: 4,
    title: "Lamp",
    iconStyle: "flaticon-table-lamp-1",
  },
  {
    id: 5,
    title: "Table",
    iconStyle: "flaticon-table",
  },
];

export const featuredProductList = Mock.mock({
  "data|30": [
    {
      id: "@natural",
      title: "@word",
      code: "@string(5)",
      "originalPrice|1-9999.1": 100,
      "currentPrice|1-9999.1": 100,
      "category|1-5": 1,
      tag: "@string(2)",
      "featured|1": ["-n%", "New", "Hot"],
      "type|1": productTypeList,
      description: "@paragraph(1)",
    },
  ],
});

export const clientFeedbackList = Mock.mock({
  "data|9": [
    {
      designation: "@word",
      author: "@name()",
      content: "@paragraph(1)",
    },
  ],
});

export const tagList = [
  {
    id: "",
    name: "",
  },
  {
    id: "",
    name: "",
  },
  {
    id: "",
    name: "",
  },
];

Mock.mock("/login", "post", (options) => {
  let data = {
    token: "12345678910",
  };
  return builder("Login Success", data);
});

Mock.mock("/logout", "delete", (options) => {
  return builder("Logout Success", null);
});

Mock.mock("/blog", "get", (options) => {
  let data = {
    "rows|20": {
      "id|+1": 1,
      title: Random.title(),
      author: "admin",
      "comment_count|1-100": 100,
      "scan_count|1-100": 100,
    },
    total: 100,
  };
  return builder("Success", data);
});

//
// export const userToken = Mock.mock(
//   "/api/front/login/mobile",
//   "POST",
//   (options) => {
//     let data = {
//       token: "123456",
//     };
//     return builder("success", data);
//   }
// );
